<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:include page="/WEB-INF/jsp/menu.jsp"/>
<!-- request scope에서 부서 목록을 가진 ArryList를 lookup해서 출력 처리 -jstl을 이용 
	1. 검색에서 호출한 경우 검색 라벨을 붙이도록 변경
	2. 목록에 부서가 있으면 목록을 출력하고 없으면 "등록된 부서가 없습니다."라는 메시지를 출력한다. 

 -->
 
 <c:choose>
 	<c:when test="${not empty requestScope.searchLabel }">
 		<h2>${requestScope.searchLabel }</h2>
 		<h3>${requestScope.searchKeyword }</h3>
 	</c:when>
 	<c:otherwise>
 		<h2>부서 목록</h2>
 	</c:otherwise>
 </c:choose>
 
 <c:choose>
 <c:when test="${fn:length(requestScope.departmentList) == 0}">
		등록된 부서가 없습니다.
	</c:when>
	<c:otherwise>
		<table width="500" border="1" cellpadding="3">
			<tr>
				<th>부서 ID</th>
				<th>부서명</th>
				<th>부서장</th>
				<th>부서인원</th>
				<th>지역</th>
				<th>수정</th>
				<th>삭제</th>
			</tr>
			<c:forEach items="${requestScope.departmentList }" var="dept">
				<tr>
					<td>${dept.departmentNum }</td>
					<td>${dept.departmentName }</td>
					<td>${dept.chiefName }</td>
					<td>${dept.departmentNunOfPeople }</td>
					<td>${dept.location }</td>
					<td align="right">
					<a href="${initParam.root}/Controller?departmentNum=${dept.departmentNum }&command=mdfc">수정</a>
					</td>
					<td align="right">
					<a href="${initParam.root}/Controller?departmentNum=${dept.departmentNum }&command=rdc">삭제</a>
					</td>
				</tr>
			</c:forEach>
		</table>	
	</c:otherwise>
 
 </c:choose>
</body>
</html>